package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cheer.entity.MallOrderFinishEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * 收货地址表
 *
 * @author cheer
 */
@Mapper
@Repository
public interface MallOrderFinishDao extends BaseMapper<MallOrderFinishEntity> {

    default List<MallOrderFinishEntity> selectListByFinishTime() {
        return selectList(new QueryWrapper<MallOrderFinishEntity>()
                .le("finish_time", new Date()));
    }

    default void updateByOrderId( Long orderId, MallOrderFinishEntity orderFinish) {
        update(orderFinish, new QueryWrapper<MallOrderFinishEntity>()
                .eq("order_id", orderId));
    }

    default void deleteByOrderId(Long orderId) {
        delete(new QueryWrapper<MallOrderFinishEntity>()
                .eq("order_id", orderId));
    }
}
